fix: reduce UI performance degradation in long conversations#12459
Open
ajayjha1 wants to merge 1 commit into
Open
fix: reduce UI performance degradation in long conversations#12459ajayjha1 wants to merge 1 commit into
ajayjha1 wants to merge 1 commit into
Conversation
- Memoize findLatestSummaryIndex with useMemo to fix O(n²) per-render scan - Extract per-message rendering into MemoizedHistoryItem (React.memo) so stable messages are skipped during streaming token updates - Pre-compute lastUserInputIndex with useMemo keyed on history.length - Remove per-child ResizeObserver loop in useAutoScroll; observe only container - Wrap StepContainer and TimelineItem with React.memo Fixes continuedev#12053
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: fix: reduce UI performance degradation in long conversations (#12053)
Fixes #12053
Description
In long conversations (500k+ tokens), the chat UI becomes progressively slower due to several compounding render inefficiencies:
These changes fix each issue without requiring virtual scrolling, keeping the diff minimal and safe.
Checklist
Screen recording or screenshot
Tested manually with a multi-turn conversation. Scrolling, streaming, and compaction display all behave correctly after the fix. A before/after profiler trace would show significantly fewer component re-renders per streaming token in long sessions.
Tests
No new tests added — the fix is purely in render/memoization logic with no changes to business logic, selectors, or reducers. Existing behaviour is preserved; only unnecessary re-renders are eliminated.
Summary by cubic
Reduce chat UI lag in long conversations by cutting O(n²) scans and avoiding unnecessary re-renders during streaming. Keeps long threads responsive; fixes #12053.
findLatestSummaryIndexwithuseMemoto remove O(n²) per-render scans.MemoizedHistoryItemwithReact.memoso stable messages don’t re-render on each token.lastUserInputIndexwithuseMemokeyed tohistory.length.StepContainerandTimelineItemwithReact.memo.useAutoScrollto observe only the container instead of each child.Written for commit 3351a0d. Summary will update on new commits. Review in cubic